using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;

namespace QCED
{
    public class Consoler
    {
        private Process cmd = new Process();

        private void Init_cmd()
        {
            cmd.StartInfo.RedirectStandardInput = true;
            cmd.StartInfo.RedirectStandardError = false;
            cmd.StartInfo.RedirectStandardOutput = false;
            cmd.StartInfo.FileName = "cmd.exe";
            cmd.StartInfo.CreateNoWindow = false;
            cmd.StartInfo.UseShellExecute = false;
            cmd.Start();
        }
        public Consoler() {
            Init_cmd();
        }

        public void Clear()
        {
            RunCommand("cls");
        }

        public void Write(string text)
        {
            cmd.StandardInput.WriteLine($"echo {text}");
        }

        public void RunCommand(string command)
        {
            cmd.StandardInput.WriteLine(command);
        }

        public void Kill()
        {
            try
            {
                cmd.Kill();
            }
            catch
            {

            }
        }
    }
}
